package com.juzhebao.buyer.mvp.model.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;


/**
 * Created by admin on 2016/12/10.
 *  抽取出来的basepager基类
 *  用于填充fragemnt的顶部导航栏效果
 *  用到的界面：
 *      订单管理
 *      商家评价
 */

public class BasePageAndTabAdapter extends FragmentPagerAdapter {
    ArrayList<Fragment> datas;
    ArrayList<String> titles;

    public BasePageAndTabAdapter(FragmentManager fm) {
        super(fm);
    }
    public void setData(ArrayList<Fragment> datas) {
        this.datas = datas;
    }

    public void setTitles(ArrayList<String> titles) {
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return datas == null ? null : datas.get(position);
    }

    @Override
    public int getCount() {
        return datas == null ? 0 : datas.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles == null ? null : titles.get(position);
    }
}
